package it.uniroma2.structure.tree;

import java.util.Vector;

import it.uniroma2.structure.Service;

public class WorkflowTreeNode {
	
	static private int idCounter = 0;
	int id;
	private Vector<Integer> father;
	private Service service;
	private boolean isChild;
	private boolean isEnd = false;
	private boolean isIf = false;
	
	//True is the service is out by rule
	private boolean isOut = false;
	
	public WorkflowTreeNode(Service service){
		this.service = service;
		idCounter++;
		this.id = this.idCounter;
		this.isChild = false;
		father = new Vector();
	}
	
	public void child(){
		this.isChild = true;
	}
	
	public boolean isChild(){
		return this.isChild;
	}
	public Service getService(){
		return service;
	}
	
	public int getId(){
		return id;
	}
	
	public void setFatherOf(int father){
		this.father.add(father);
	}
	
	public int getFatherOf(int pos){
		if(this.father.size() - 1 >= pos){
			return this.father.elementAt(pos);
		}
		return -1;
	}
	
	public Vector<Integer> getFatherVect(){
		return this.father;
	}
	
	public void setEnd(){
		this.isEnd = true;
	}
	
	public boolean isEnd(){
		return this.isEnd;
	}
	
	public void eliminateService(){
		this.isOut = true;
	}
	
	public boolean isOut(){
		return this.isOut;
	}
	
	public boolean isIf(){
		return isIf;
	}
	
	public void setIf(){
		this.isIf = true;
	}
}
